<%@ page contentType="text/html;charset=utf-8" language="java"%>
<%@ taglib uri='http://java.sun.com/jsp/jstl/core' prefix='c'%>
<%@ taglib uri='http://java.sun.com/jsp/jstl/functions' prefix='fn'%>
<c:set var="path" value="${pageContext.request.contextPath}"/>
<head>
   <link rel="icon" href="../favicon.ico" type="image/x-icon"/> 
	 <link rel="shortcut icon" href="../favicon.ico" type="image/x-icon"/>
</head>
<script type="text/javascript" charset="utf-8" src="http://static.bshare.cn/b/buttonLite.js#uuid=05178548-8fa7-4f88-9410-7a371e422034&style=-1"></script>
<script >
var loginUserId = "${sessionScope.loginUser.userId}";
var loginCardId = "${sessionScope.userCard.cardId}";
var loginCardBackGround = "${sessionScope.userCard.background}";
var imgDomain = "http://youoor.qiniudn.com/";
var chars = ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
function initBshare(cardId,pic) {
	bShare.addEntry({
	    title: "有而就是有范",
	    url: "http://www.youoor.com/viewCard.jsp?cardId="+cardId,
	    summary: "有而就是有范儿",
	    pic: imgDomain+pic
	});
}

function checkLogin() {
	if(!loginUserId) {
		alert("请登录!");
		window.location.href='${path}/index.jsp';
		return false;
	}else{
		return true;
	}
}

function generateMixed(n) {
     var res = "";
     for(var i = 0; i < n ; i ++) {
         var id = Math.ceil(Math.random()*35);
         res += chars[id];
     }
     return res;
}
function GetRandomNum(Min,Max)
{   
	var Range = Max - Min;   
	var Rand = Math.random();   
	return(Min + Math.round(Rand * Range));   
}   
function request(paras){ 
    var url = location.href; 
    var paraString = url.substring(url.indexOf("?")+1,url.length).split("&"); 
    var paraObj = {} 
    for (i=0; j=paraString[i]; i++){ 
        paraObj[j.substring(0,j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=")+1,j.length); 
    } 

    var returnValue = paraObj[paras.toLowerCase()]; 
    if(typeof(returnValue)=="undefined"){ 
        return ""; 
    }else{ 
        return returnValue; 
    } 
}

function formatLinkData(linksObj) {
	var linkDiv = "";
     if (linksObj) {
  	   for (var t =0 ;t<linksObj.length;t++) {
  		   var linkUrl = linksObj[t].linkUrl.toLowerCase();
  		   var realLink=getlink(linkUrl);
  		   if (linkUrl.indexOf("weibo") >=0){
  					linkDiv =linkDiv+"<li><a href=\""+realLink+"\" class=\"sina\" target=\"_blank\"></a></li>";
			}else if (linkUrl.indexOf("t.qq") >= 0) {
				linkDiv =linkDiv+"<li><a href=\""+realLink+"\" class=\"tengxun\" target=\"_blank\"></a></li>";
			}else if (linkUrl.indexOf("kaixin001") >= 0) {
				linkDiv =linkDiv+"<li><a href=\""+realLink+"\" class=\"happy\" target=\"_blank\"></a></li>";
			}else if (linkUrl.indexOf("renren") >= 0) {
				linkDiv =linkDiv+"<li><a href=\""+realLink+"\" class=\"renren\" target=\"_blank\"></a></li>";
			}else if (linkUrl.indexOf("qzone") >= 0) {
				linkDiv =linkDiv+"<li><a href=\""+realLink+"\" class=\"tengxunpengyouquan\" target=\"_blank\"></a></li>";
			}else if (linkUrl.indexOf("douban") >= 0) {
				linkDiv =linkDiv+"<li><a href=\""+realLink+"\" class=\"douban\" target=\"_blank\"></a></li>";
			}else if (linkUrl.indexOf("linkedin") >= 0) {
				linkDiv =linkDiv+"<li><a href=\""+realLink+"\" class=\"linkedin\" target=\"_blank\"></a></li>";
			}else if (linkUrl.indexOf("taobao") >= 0) {
				linkDiv =linkDiv+"<li><a href=\""+realLink+"\" class=\"taobao\" target=\"_blank\"></a></li>";
			}else if (linkUrl.indexOf("tmall") >= 0) {
				linkDiv =linkDiv+"<li><a href=\""+realLink+"\" class=\"tmall\" target=\"_blank\"></a></li>";
			}else if (linkUrl.indexOf("qunar") >= 0) {
				linkDiv =linkDiv+"<li><a href=\""+realLink+"\" class=\"qunar\" target=\"_blank\"></a></li>";
			}else if (linkUrl.indexOf("jd") >= 0) {
				linkDiv =linkDiv+"<li><a href=\""+realLink+"\" class=\"jd\" target=\"_blank\"></a></li>";
			}else if (linkUrl.indexOf("ctrip") >= 0) {
				linkDiv =linkDiv+"<li><a href=\""+realLink+"\" class=\"xiecheng\" target=\"_blank\"></a></li>";
			}else if (linkUrl.indexOf("blog") >= 0) {
				linkDiv =linkDiv+"<li><a href=\""+realLink+"\" class=\"blog\" target=\"_blank\"></a></li>";
			}else if (linkUrl.indexOf("meilishuo") >= 0 ||linkUrl.indexOf("mogujie") >= 0||linkUrl.indexOf("duitang") >= 0) {
				linkDiv =linkDiv+"<li><a href=\""+realLink+"\" class=\"socialShop\" target=\"_blank\"></a></li>";
			}else if (linkUrl.indexOf("youku") >= 0||linkUrl.indexOf("iqiyi") >= 0||linkUrl.indexOf("tudou") >= 0||linkUrl.indexOf("tv.sohu") >= 0||linkUrl.indexOf("v.qq") >= 0||linkUrl.indexOf("letv") >= 0) {
				linkDiv =linkDiv+"<li><a href=\""+realLink+"\" class=\"vdieo\" target=\"_blank\"></a></li>";
			}else  {
				linkDiv =linkDiv+"<li><a href=\""+realLink+"\" class=\"other\" target=\"_blank\"></a></li>";
			}
  	  }
     }
    /* linkDiv =linkDiv+"<li><a href=\"#\" class=\"wechat\"></a>"+
	   "<div class=\"wechat-2code hide-el\" style=\"display:none;\">"+
	   "<p>微信二维码</p>"+
	   "<img alt=\"二维码\" src=\"image/icon-code.gif\" />"+
	   "</div></li>";*/
	 return linkDiv;
}
function cancelFavoCard(cardId) {
	objp= {}
	objp.cardId = cardId
	   $.ajax({
			  url: '${path}/core/cancelFavoCard',
			  type: 'POST',
			  timeout: 30000,
			  cache : false,
		      data :objp,
		      async: false,
			  success:function(msg){
				  alert("已取消");
				  history.go(0);
			   },
			   failure:function(msg){
				   alert(eval('('+msg.responseText+')').error_text);
			   		
			   },
			   error:function(msg){
				   alert(eval('('+msg.responseText+')').error_text); 
			   }
		});
}
/**
 * 收藏
 */
function favoCard(cardId) {
	objp= {}
	objp.cardId = cardId
	   $.ajax({
			  url: '${path}/core/favoCard',
			  type: 'POST',
			  timeout: 30000,
			  cache : false,
		      data :objp,
		      async: false,
			  success:function(msg){
				  alert("收藏成功");
			   },
			   failure:function(msg){
				   alert(eval('('+msg.responseText+')').error_text);
			   		
			   },
			   error:function(msg){
				   alert(eval('('+msg.responseText+')').error_text); 
			   }
		});
}

function hi(cardId) {
	objp= {}
	objp.cardId = cardId
	   $.ajax({
			  url: '${path}/core/hi',
			  type: 'POST',
			  timeout: 30000,
			  cache : false,
		      data :objp,
		      async: false,
			  success:function(msg){
				  alert("已发送！");
			   },
			   failure:function(msg){
				   alert(eval('('+msg.responseText+')').error_text);
			   		
			   },
			   error:function(msg){
				   alert(eval('('+msg.responseText+')').error_text); 
			   }
		});
}
function sendMailByYouoor(cardId,title,content) {
	objp= {}
	objp.cardId = cardId;
	objp.title = title;
	objp.content = content;
	   $.ajax({
			  url: '${path}/core/sendMailByYouoor',
			  type: 'POST',
			  timeout: 30000,
			  cache : false,
		      data :objp,
		      async: false,
			  success:function(msg){
				  alert("已发送！");
			   },
			   failure:function(msg){
				   alert(eval('('+msg.responseText+')').error_text);
			   		
			   },
			   error:function(msg){
				   alert(eval('('+msg.responseText+')').error_text); 
			   }
		});
}

function toViewCard(cardId) {
	window.location.href='${path}/viewCard.jsp?cardId='+cardId;
}


function onMouseOverShare(cardId,subCardId,pic) {
	//$("#cardShareId"+cardId).css("display","block");
	//$(this).hover(function(){
		$("#"+cardId).children("div").css("display","block");
		initBshare(subCardId,pic);
		//$("#"+cardId).addClass("share-op-on");
		
	//});
}
function onMouseOutShare(cardId) {
	//$("#cardShareId"+cardId).css("display","none");
	$("#"+cardId).children("div").css("display","none");
	//$("#"+cardId).removeClass("share-op-on");
}

function getlink(link){
	if(link) {
		link = link.trim();
		if(!(link.substring(0,4)=="http")) {
			link= "http://"+link;
		}
		
	}
	return link;
}

</script>


